#include"../sock.h"

#define BUF_SIZE 1024

int main()
{
    int sfd = socket(AF_UNIX , SOCK_STREAM,0);
    if(sfd == -1) 
        errExit("socket");
    Sockaddr_un addr;
    ini_path(AF_UNIX,&addr,"\0test");
    
    if(connect(sfd,(struct sockaddr *) &addr,sizeof (struct sockaddr_un) ) == -1)
        errExit("connect");
    
    char buf[BUF_SIZE];

    int numRead = 0;
    // 接受
    while((numRead = read(STDIN_FILENO,buf,BUF_SIZE)) > 0)
        if(write(sfd,buf,numRead) != numRead) 
            fatal("partial/failed write");
    if(numRead == -1)
        errExit("read");
    return 0;
}